package com.money.mvp_dagger_simple.presenter.impl;

import android.util.Log;

import com.money.mvp_dagger_simple.application.Mapplication;
import com.money.mvp_dagger_simple.model.LoginModel;
import com.money.mvp_dagger_simple.presenter.ILoginPresenter;
import com.money.mvp_dagger_simple.presenter.component.DaggerLoginPresenterComponent;
import com.money.mvp_dagger_simple.presenter.module.LoginPresenterModule;
import com.money.mvp_dagger_simple.ui.activity.LoginActivity;
import com.money.mvp_dagger_simple.ui.view.LoginView;

import javax.inject.Inject;

/**
 * Created by Money on 2017/8/28.
 */

public class ILoginPresenterImpl implements ILoginPresenter{

    private static final String TAG = ILoginPresenterImpl.class.getSimpleName();

    private LoginActivity loginActivity;
    private LoginView loginView;


    @Inject
    LoginModel loginModel;

    public ILoginPresenterImpl(LoginActivity loginActivity, LoginView loginView) {
        this.loginActivity = loginActivity;
        this.loginView = loginView;

        DaggerLoginPresenterComponent.builder()
                .appComponent(Mapplication.getAppComponent())
                .loginPresenterModule(new LoginPresenterModule(this))
                .build()
                .inject(this);
        Log.e(TAG, "LoginModel:" + loginModel);
    }

    @Override
    public void login() {

        loginModel.login(loginView.getAccount(), loginView.getPassword());
    }

    @Override
    public void loginSuccess() {
        loginView.loginSuccess();
    }

    @Override
    public void loginFailure() {
        loginView.loginFailure();
    }
}
